<?php

class DateBox extends HTMLElement 
{
	
	/**
	 * @var SelectBox
	 */
	private $dayBox;
	/**
	 * @var SelectBox
	 */
	private $monthBox;
	/**
	 * @var SelectBox
	 */
	private $yearBox;
	
	public function __construct($name)
	{
		$this->name = $name;
		
		$this->dayBox = new SelectBox($name.'[day]', date('j') - 1);
		$this->dayBox->setCSSClass('day');
		for($i = 1; $i <= 31; $i++)
		{
			$this->dayBox->addOption($i, $i);
		}
		
		$this->monthBox = new SelectBox($name.'[month]', date('n') - 1);
		$this->monthBox->setCSSClass('month');		
		$months = array('januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december');
		
		for($i = 0; $i < 12; $i++)
		{
			$this->monthBox->addOption($months[$i], $i+1);
		}
		
		$this->yearBox = new SelectBox($name.'[year]', 2010);
		$this->yearBox->setCSSClass('year');
		for($i = date('Y'); $i >= date('Y') - 5; $i--)
		{
			$this->yearBox->addOption($i, $i);
		}
	}
	
	public function getHTML()
	{
		return $this->dayBox->getHTML() . $this->monthBox->getHTML() . $this->yearBox->getHTML();
	}
}